.class public Lcom/zuiapps/suite/utils/image/RoundImageView;
.super Landroid/widget/ImageView;
.source "RoundImageView.java"


# static fields
.field private static final DEFAULT_BORDER_COLOR:I = 0x0

.field private static final DEFAULT_BORDER_WIDTH:I = 0x0

.field private static final DEFAULT_RADIUS:I = -0x1


# instance fields
.field private mBorderColor:I

.field private mBorderPaint:Landroid/graphics/Paint;

.field private mBorderWidth:I

.field private mRadius:I


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .registers 3
    .param p1, "context"    # Landroid/content/Context;

    .prologue
    .line 31
    invoke-direct {p0, p1}, Landroid/widget/ImageView;-><init>(Landroid/content/Context;)V

    .line 25
    const/4 v0, -0x1

    iput v0, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mRadius:I

    .line 32
    const/4 v0, 0x0

    invoke-direct {p0, p1, v0}, Lcom/zuiapps/suite/utils/image/RoundImageView;->init(Landroid/content/Context;Landroid/util/AttributeSet;)V

    .line 33
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
    .registers 4
    .param p1, "context"    # Landroid/content/Context;
    .param p2, "attrs"    # Landroid/util/AttributeSet;

    .prologue
    .line 36
    invoke-direct {p0, p1, p2}, Landroid/widget/ImageView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V

    .line 25
    const/4 v0, -0x1

    iput v0, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mRadius:I

    .line 37
    invoke-direct {p0, p1, p2}, Lcom/zuiapps/suite/utils/image/RoundImageView;->init(Landroid/content/Context;Landroid/util/AttributeSet;)V

    .line 38
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V
    .registers 5
    .param p1, "context"    # Landroid/content/Context;
    .param p2, "attrs"    # Landroid/util/AttributeSet;
    .param p3, "defStyle"    # I

    .prologue
    .line 41
    invoke-direct {p0, p1, p2, p3}, Landroid/widget/ImageView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V

    .line 25
    const/4 v0, -0x1

    iput v0, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mRadius:I

    .line 42
    invoke-direct {p0, p1, p2}, Lcom/zuiapps/suite/utils/image/RoundImageView;->init(Landroid/content/Context;Landroid/util/AttributeSet;)V

    .line 43
    return-void
.end method

.method private init(Landroid/content/Context;Landroid/util/AttributeSet;)V
    .registers 10
    .param p1, "context"    # Landroid/content/Context;
    .param p2, "attrs"    # Landroid/util/AttributeSet;

    .prologue
    const/4 v6, 0x0

    const/4 v5, -0x1

    .line 46
    sget-object v4, Lcom/zuiapps/suite/utils/R$styleable;->RoundImage:[I

    invoke-virtual {p1, p2, v4}, Landroid/content/Context;->obtainStyledAttributes(Landroid/util/AttributeSet;[I)Landroid/content/res/TypedArray;

    move-result-object v0

    .line 47
    .local v0, "a":Landroid/content/res/TypedArray;
    sget v4, Lcom/zuiapps/suite/utils/R$styleable;->RoundImage_round_image_radius:I

    invoke-virtual {v0, v4, v5}, Landroid/content/res/TypedArray;->getDimensionPixelSize(II)I

    move-result v3

    .line 48
    .local v3, "radius":I
    if-ne v3, v5, :cond_16

    .line 49
    sget v4, Lcom/zuiapps/suite/utils/R$styleable;->RoundImage_radius:I

    invoke-virtual {v0, v4, v5}, Landroid/content/res/TypedArray;->getInt(II)I

    move-result v3

    .line 51
    :cond_16
    sget v4, Lcom/zuiapps/suite/utils/R$styleable;->RoundImage_round_image_border_width:I

    invoke-virtual {v0, v4, v6}, Landroid/content/res/TypedArray;->getDimensionPixelSize(II)I

    move-result v2

    .line 52
    .local v2, "borderWidth":I
    sget v4, Lcom/zuiapps/suite/utils/R$styleable;->RoundImage_round_image_border_color:I

    invoke-virtual {v0, v4, v6}, Landroid/content/res/TypedArray;->getColor(II)I

    move-result v1

    .line 53
    .local v1, "borderColor":I
    invoke-virtual {p0, v3}, Lcom/zuiapps/suite/utils/image/RoundImageView;->setRadius(I)V

    .line 54
    invoke-virtual {p0, v2}, Lcom/zuiapps/suite/utils/image/RoundImageView;->setBorderWidth(I)V

    .line 55
    invoke-virtual {p0, v1}, Lcom/zuiapps/suite/utils/image/RoundImageView;->setBorderColor(I)V

    .line 56
    invoke-virtual {v0}, Landroid/content/res/TypedArray;->recycle()V

    .line 58
    new-instance v4, Landroid/graphics/Paint;

    invoke-direct {v4}, Landroid/graphics/Paint;-><init>()V

    iput-object v4, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mBorderPaint:Landroid/graphics/Paint;

    .line 59
    iget-object v4, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mBorderPaint:Landroid/graphics/Paint;

    const/4 v5, 0x1

    invoke-virtual {v4, v5}, Landroid/graphics/Paint;->setAntiAlias(Z)V

    .line 60
    iget-object v4, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mBorderPaint:Landroid/graphics/Paint;

    sget-object v5, Landroid/graphics/Paint$Style;->STROKE:Landroid/graphics/Paint$Style;

    invoke-virtual {v4, v5}, Landroid/graphics/Paint;->setStyle(Landroid/graphics/Paint$Style;)V

    .line 62
    return-void
.end method


# virtual methods
.method public getBorderColor()I
    .registers 2

    .prologue
    .line 91
    iget v0, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mBorderColor:I

    return v0
.end method

.method public getBorderWidth()I
    .registers 2

    .prologue
    .line 83
    iget v0, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mBorderWidth:I

    return v0
.end method

.method public getRadius()I
    .registers 2

    .prologue
    .line 79
    iget v0, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mRadius:I

    return v0
.end method

.method protected onDraw(Landroid/graphics/Canvas;)V
    .registers 14
    .param p1, "canvas"    # Landroid/graphics/Canvas;

    .prologue
    const/4 v11, 0x0

    .line 100
    invoke-virtual {p0}, Lcom/zuiapps/suite/utils/image/RoundImageView;->getDrawable()Landroid/graphics/drawable/Drawable;

    move-result-object v0

    check-cast v0, Landroid/graphics/drawable/BitmapDrawable;

    .line 102
    .local v0, "drawable":Landroid/graphics/drawable/BitmapDrawable;
    if-nez v0, :cond_a

    .line 146
    :cond_9
    :goto_9
    return-void

    .line 106
    :cond_a
    invoke-virtual {p0}, Lcom/zuiapps/suite/utils/image/RoundImageView;->getWidth()I

    move-result v9

    if-eqz v9, :cond_9

    invoke-virtual {p0}, Lcom/zuiapps/suite/utils/image/RoundImageView;->getHeight()I

    move-result v9

    if-eqz v9, :cond_9

    .line 110
    invoke-virtual {v0}, Landroid/graphics/drawable/BitmapDrawable;->getBitmap()Landroid/graphics/Bitmap;

    move-result-object v1

    .line 111
    .local v1, "fullSizeBitmap":Landroid/graphics/Bitmap;
    if-eqz v1, :cond_9

    .line 115
    invoke-virtual {p0}, Lcom/zuiapps/suite/utils/image/RoundImageView;->getMeasuredWidth()I

    move-result v9

    iget v10, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mBorderWidth:I

    mul-int/lit8 v10, v10, 0x2

    sub-int v8, v9, v10

    .line 116
    .local v8, "scaledWidth":I
    invoke-virtual {p0}, Lcom/zuiapps/suite/utils/image/RoundImageView;->getMeasuredHeight()I

    move-result v9

    iget v10, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mBorderWidth:I

    mul-int/lit8 v10, v10, 0x2

    sub-int v7, v9, v10

    .line 119
    .local v7, "scaledHeight":I
    invoke-virtual {v1}, Landroid/graphics/Bitmap;->getWidth()I

    move-result v9

    if-ne v8, v9, :cond_8a

    invoke-virtual {v1}, Landroid/graphics/Bitmap;->getHeight()I

    move-result v9

    if-ne v7, v9, :cond_8a

    .line 120
    move-object v2, v1

    .line 125
    .local v2, "mScaledBitmap":Landroid/graphics/Bitmap;
    :goto_3d
    iget v3, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mRadius:I

    .line 126
    .local v3, "radius":I
    const/4 v9, -0x1

    if-ne v3, v9, :cond_46

    .line 127
    if-le v7, v8, :cond_90

    div-int/lit8 v3, v8, 0x2

    .line 130
    :cond_46
    :goto_46
    iget-object v9, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mBorderPaint:Landroid/graphics/Paint;

    iget v10, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mBorderColor:I

    invoke-virtual {v9, v10}, Landroid/graphics/Paint;->setColor(I)V

    .line 131
    iget-object v9, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mBorderPaint:Landroid/graphics/Paint;

    iget v10, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mBorderWidth:I

    int-to-float v10, v10

    invoke-virtual {v9, v10}, Landroid/graphics/Paint;->setStrokeWidth(F)V

    .line 132
    new-instance v4, Landroid/graphics/Rect;

    invoke-virtual {p0}, Lcom/zuiapps/suite/utils/image/RoundImageView;->getMeasuredWidth()I

    move-result v9

    invoke-virtual {p0}, Lcom/zuiapps/suite/utils/image/RoundImageView;->getMeasuredHeight()I

    move-result v10

    invoke-direct {v4, v11, v11, v9, v10}, Landroid/graphics/Rect;-><init>(IIII)V

    .line 133
    .local v4, "rect":Landroid/graphics/Rect;
    new-instance v5, Landroid/graphics/RectF;

    invoke-direct {v5, v4}, Landroid/graphics/RectF;-><init>(Landroid/graphics/Rect;)V

    .line 134
    .local v5, "rectF":Landroid/graphics/RectF;
    int-to-float v9, v3

    iget v10, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mRadius:I

    int-to-float v10, v10

    iget-object v11, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mBorderPaint:Landroid/graphics/Paint;

    invoke-virtual {p1, v5, v9, v10, v11}, Landroid/graphics/Canvas;->drawRoundRect(Landroid/graphics/RectF;FFLandroid/graphics/Paint;)V

    .line 136
    int-to-float v9, v3

    invoke-static {v2, v9}, Lcom/zuiapps/suite/utils/image/ImageUtils;->getRoundedCornerBitmap(Landroid/graphics/Bitmap;F)Landroid/graphics/Bitmap;

    move-result-object v6

    .line 137
    .local v6, "roundBitmap":Landroid/graphics/Bitmap;
    iget v9, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mBorderWidth:I

    int-to-float v9, v9

    iget v10, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mBorderWidth:I

    int-to-float v10, v10

    const/4 v11, 0x0

    invoke-virtual {p1, v6, v9, v10, v11}, Landroid/graphics/Canvas;->drawBitmap(Landroid/graphics/Bitmap;FFLandroid/graphics/Paint;)V

    .line 138
    if-eq v2, v1, :cond_84

    .line 139
    invoke-virtual {v2}, Landroid/graphics/Bitmap;->recycle()V

    .line 142
    :cond_84
    if-eqz v6, :cond_9

    .line 143
    invoke-virtual {v6}, Landroid/graphics/Bitmap;->recycle()V

    goto :goto_9

    .line 122
    .end local v2    # "mScaledBitmap":Landroid/graphics/Bitmap;
    .end local v3    # "radius":I
    .end local v4    # "rect":Landroid/graphics/Rect;
    .end local v5    # "rectF":Landroid/graphics/RectF;
    .end local v6    # "roundBitmap":Landroid/graphics/Bitmap;
    :cond_8a
    const/4 v9, 0x1

    invoke-static {v1, v8, v7, v9}, Landroid/graphics/Bitmap;->createScaledBitmap(Landroid/graphics/Bitmap;IIZ)Landroid/graphics/Bitmap;

    move-result-object v2

    .restart local v2    # "mScaledBitmap":Landroid/graphics/Bitmap;
    goto :goto_3d

    .line 127
    .restart local v3    # "radius":I
    :cond_90
    div-int/lit8 v3, v7, 0x2

    goto :goto_46
.end method

.method public setBorderColor(I)V
    .registers 2
    .param p1, "borderColor"    # I

    .prologue
    .line 95
    iput p1, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mBorderColor:I

    .line 96
    return-void
.end method

.method public setBorderWidth(I)V
    .registers 2
    .param p1, "borderWidth"    # I

    .prologue
    .line 87
    iput p1, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mBorderWidth:I

    .line 88
    return-void
.end method

.method public setRadius(I)V
    .registers 2
    .param p1, "radius"    # I

    .prologue
    .line 70
    iput p1, p0, Lcom/zuiapps/suite/utils/image/RoundImageView;->mRadius:I

    .line 71
    invoke-virtual {p0}, Lcom/zuiapps/suite/utils/image/RoundImageView;->invalidate()V

    .line 72
    return-void
.end method
